<?php

	/**
	 * @see Bike_Js_Base
	 */
	require_once 'Bike/Js/Base.php';
	
	
	class Bike_Js_Location extends Bike_Js_Base
	{
		public function makeOptions(array $Args=null)
		{
			$options = array();
			$argsCount = sizeof($Args);
			if($argsCount == 1 && is_array($Args[0]) && isset($Args[0]['url']))
			{
				$options = $Args[0];
			}
			elseif($argsCount >= 1)
			{				$options['url'] = $Args[0];
			}
			return $options;
		}

		protected function initDefaultSettings()
		{
			parent::initDefaultSettings();
		
			$this->setSettings(array(
				'method' => 'replace',
			));
		}

		public function __call($MethodName, array $Args=null)
		{			switch($MethodName)
			{				case 'reload':
				case 'replace': 	$this->method = $MethodName;
									if(!is_null($Args[0]))
									{										$this->url = $Args[0];
									}
									return $this;
				default:			return parent::__call($MethodName, $Args);
			}
		}

		public function _toString()
		{			return (string) call_user_func(array($this->js()->window->location, $this->method), $this->url);
		}
	}
